<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib uri="/struts-tags" prefix="s" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML>
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>后台管理</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	 <meta charset="UTF-8">
    <title>后台管理</title>
    <link rel="stylesheet" type="text/css" href="UI/admins/css/common.css"/>
    <link rel="stylesheet" type="text/css" href="UI/admins/css/main.css"/>
    <script type="text/javascript" src="UI/admins/js/libs/modernizr.min.js"></script>
	
  </head>
  
  <body>
	
    <!--/sidebar-->

        <div class="crumb-wrap">

            <div class="crumb-list"><i class="icon-font"></i>首页<span class="crumb-step">&gt;</span><a class="crumb-name" href="listAllMachine">自助终端管理</a><span class="crumb-step">&gt;</span><span>新增终端</span></div>
        </div>
        <div class="result-wrap">
            <div class="result-content">
            	<s:form action="addMachine" method="post">
                    <table class="insert-tab" width="100%">
                        <tbody>
                            <tr>
                                <th width="120"><i class="require-red">*</i>IP地址：</th>
                                <td>
                                    <s:textfield name="ipAddress"  class="common-text required" ></s:textfield>
                                </td>
                            </tr>

                            <tr>
                                <th><i class="require-red">*</i>所属片区：</th>
                                <td>
                                	<s:select  name="address1" list="listmachineaddress" listKey="id" listValue="name"></s:select>
                                </td>
                            </tr>
                            <tr>
                                <th><i class="require-red">*</i>详细地址：</th>
                                <td>
                                	<s:textfield name="address2"  class="common-text required" ></s:textfield>
                                </td>
                            </tr>
                            <tr>
                                <th><i class="require-red">*</i>片区负责人：</th>
                                <td>
                                	<s:select  name="admin.id" list="listadmin" listKey="id" listValue="name"></s:select>
                                </td>
                            </tr>
                            <tr>
                                <th><i class="require-red">*</i>柜子总数：</th>
                                <td>
                                	<s:textfield name="numAll"  class="common-text required" ></s:textfield>
                                </td>
                            </tr>
                            <tr>
                                <th></th>
                                <td>

                                    <input class="btn btn-primary btn6 mr10" value="提交" type="submit">
                                    <input class="btn btn6" onclick="history.go(-1)" value="返回" type="button">
                                </td>
                            </tr>
                        </tbody></table>
                </s:form>
            </div>
        </div>

    <!--/main-->
    
  	<script type="text/javascript" language="javascript">
$(document).ready(function(){
		//获取一级地址
	$.post("getMachineAddressFirst.action",function(data){      //data代表服务器端传来的数据
		var jsonObj=eval("("+data+")");                    //封装服务器数据为json对象
		for(var i=0;i<jsonObj.length;i++){
			var $option=$("<option></option>");
			$option.attr("value",jsonObj[i].mid);
			$option.text(jsonObj[i].mname);
			$("#address1").append($option);
		}
	});
	//获取二级地址
	$("#address1").change(function(){
		$.post("getMachineAddressSecond.action",{mid:$("#address1").val()},function(data){
			//清空二级地址
			$("#address2 option[value!='']").remove();
			var jsonObj=eval("("+data+")");
			for(var i=0;i<jsonObj.length;i++){
				var $option=$("<option></option>");
				$option.attr("value",jsonObj[i].mid);
				$option.text(jsonObj[i].mname);
				$("#address2").append($option);
			}
		});
	});
});

</script> 
  </body>
</html>
